/*
 * @作者: kerwin
 * @公众号: 大前端私房菜
 */
import React, { Component } from 'react'
import { BrowserRouter, Routes, Route } from 'react-router-dom'
import Films from '../views/Films'
import Cinemas from '../views/Cinemas'
import Center from '../views/Center'
import Detail from '../views/Detail'
import NotFound from '../views/NotFound'
import Login from '../views/Login'
import Nowplaying from '../views/films/Nowplaying'
import Comingsoon from '../views/films/Comingsoon'
import City from '../views/City'
import Search from '../views/Search'
// function isAuth() {
//     return localStorage.getItem("token")
// }


// BrowserRouter 没有#的路径，好看 ，真正朝后端发请求要页面，后端没有对应的路径处理路径， 就会404， 不好看。
export default class IndexRouter extends Component {
    render () {
        return (
            <BrowserRouter>
                {this.props.children}
                <Routes>
                    <Route path="/films" element={<Films />} >
                        {/*嵌套路由 */}
                        <Route index element={<Nowplaying />}></Route>
                        <Route path="/films/comingsoon" element={<Comingsoon />} />
                    </Route>
       
                    <Route path="/cinemas" element={<Cinemas />} />
                    <Route path="/films/search" element={<Search />} />
                    <Route path="/center" element={<Center />} />

                    <Route path="/login" element={<Login />} />

                    <Route path="/city" element={<City />} />
                    {/* /detail/1111  动态路由 */}
                    <Route path="/detail/:id" element={<Detail />} />

                    {/* 模糊匹配 */}
                    <Route path='*' element={<NotFound />} />
                </Routes>

            </BrowserRouter>

        )
    }
}

// class Route extends Component{
//     ...

//     render(){
//         var MyComponent = this.props.component
//     return <div>
//             <MyComponent history={} match={}.../>
//         </div>
//     }
// }